package logic

import (
	"context"
	"zhaowei/models/mysql"

	"zhaowei/baidurpc/baidurpc"
	"zhaowei/baidurpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type TypesAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewTypesAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TypesAddLogic {
	return &TypesAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *TypesAddLogic) TypesAdd(in *baidurpc.TypesAddRequest) (*baidurpc.TypesAddResponse, error) {
	// todo: add your logic here and delete this line
	var typ mysql.Types
	typ.Name = in.Name
	mysql.DB.Debug().Create(&typ)
	return &baidurpc.TypesAddResponse{
		Id: int64(typ.ID),
	}, nil
}
